package com.myl.core.basic;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * BaseEntity
 * author: myl <ixiaomu@qq.com> 2024/1/9
 * tips:
 */
@Data
public abstract class BaseEntity  implements Serializable {


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * 唯一ID
     */
    @Schema(description = "唯一ID")
    @TableId(value = "id", type = IdType.AUTO)
    protected Long id;

    /**
     * 更新时间
     */
    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateTime;

    /**
     * 添加时间
     */
    @Schema(description = "添加时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    protected LocalDateTime createTime;

    /**
     * 状态 1正常 2禁用
     */
    @Schema(description = "状态 1正常 2禁用")
    @TableField(value = "status")
    protected Integer status;

    /**
     * 删除 0未删除1已删除
     */
    @JsonIgnore
    @Schema(description = "删除状态 0未删除1已删除")
    @TableField(value = "is_deleted")
    protected Integer isDeleted;

    /**
     * 接收post请求传递过来的条件查询params参数，而不需要另外创建Vo。
     */
    @TableField(exist = false)
    protected Map<String, Object> params;

}
